﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EntityModel
{
    public class HallDbContext:DbContext
    {
        /// <summary>
        /// 数据上下文
        /// </summary>
        /// <param name="opts"></param>
        public HallDbContext(DbContextOptions<HallDbContext> opts) : base(opts)
        {

        }
        /// <summary>
        /// 人员信息映射
        /// </summary>
        public DbSet<User> User { get; set; }

        /// <summary>
        /// 菜谱映射
        /// </summary>
        public DbSet<BillFare> BillFare { get; set; }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<User>().HasData([
                new User(){
                    FirstName="张",
                    LastName="三",
                    Type=0,
                    Pay=12000,
                    Gender=true,
                    Age=25,
                    AddTime=DateTime.Now
                },
                new User(){
                    FirstName="王",
                    LastName="五",
                    Type=1,
                    Pay=8000,
                    Gender=true,
                    Age=23,
                    AddTime=DateTime.Now
                }
            ]);
        }
    }
}
